#!/usr/bin/python
#-*- coding: utf-8  -*-
import os,sys,json,time
'''
Created on 2016年6月3日

@author: sunying
'''

if __name__ == '__main__':
    print 1
#     a= '{"task_name":"test","host":"www.baidu.com","udp_port":"80","frequency":"2","retry":"1","history":"0","request_format":"0","request_str":"dfdfd","pattern_format":"0","pattern_str":"dfsfsfsfsf","redirect":"","param":null,"task_type":"udp","use_dns_ip":"0","metric_ip":null,"use_dns_domain":"0","metric_domain":null,"use_dns_server":"0","class_id":"","monitors":{"1":"\u897f\u5b89\u7535\u4fe1","11":"\u4e0a\u6d77\u7535\u4fe1","12":"\u6df1\u5733\u7535\u4fe1","15":"\u6d59\u6c5f\u7535\u4fe1","2":"\u5927\u8fde\u8054\u901a","14":"\u5317\u4eac\u8054\u901a","125":"\u5929\u6d25\u79fb\u52a8","31":"\u53f0\u6e7e\u53f0\u5317","51":"\u7f8e\u56fd\u8fbe\u62c9\u65af","52":"\u7f8e\u56fd\u65e7\u91d1\u5c71"}}'
#     a= '{"task_id":"19657","task_name":"apache051101","task_type":"apache","frequency":"120","last_check_time":"2016-09-05 11:21:13","task_status":"\u5f00\u542f","status_led":"green","status_str":"\u6b63\u5e38"}'
    a =[{"task_id":"19657","task_name":"apache051101"},{"task_id":"11","task_name":"aa"}]  
#     print type(a)
#     fd1= json.dumps(a)
#     fd = json.loads(a)
#     print fd.keys()
    if isinstance(a, list):
        for dict in a:
            print dict , type(dict)
            d=dict .keys()
            print  d , type(d)
            s1 = '\n'.join(d)
            print s1
#             if d !=0
#             break
    else:
        result_dict = json.loads(a)
        print  result_dict
#     print result_dict, type(a)
        a=result_dict .keys()   
        print  a
        s = '\n'.join(a)
        print s

#     b='{“task_name”:“iptraceroutetrue”,“host”:“180.150.177.153”,“frequency”:“2”,“retry”:“1”,“history”:“1”,“redirect”:“”,“param”:null,“task_type”:“traceroute”,“use_dns_ip”:“0”,“metric_ip”:null,“use_dns_domain”:“0”,“metric_domain”:null,“use_dns_server”:“0”,“class_id”:“17966”,“monitors”:{“1”:“陕西西安电信”}}'
#     result_dict1= json.loads(b)
# #     print result_dict, type(a)
#     d=result_dict1 .keys()
#     print  d
#     s1 = ','.join(d)
#     print s1

# 对于python中字典中有列表的形式，如何遍历并取值
# e={'11542': ['6326', '467', '332', '13058', '11542'], '11543': ['6326', '11543']}
# for key in e:
# for value in e[key]:
# print value
 


   